package com.mingqijia.gassafety.shared.constant;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

@Getter
@RequiredArgsConstructor
public enum PushMsgEnum {

    //TYPE_1(1,"Bj1","报警器泄漏","尊敬的用户，报警器检测到燃气泄漏，请注意用气安全！请关闭气源，开门开窗通风及拨打本地燃气热线电话：%s。"),
    TYPE_1(1,"Bj1","燃气报警器泄漏报警","您的燃气报警器检测到燃气泄漏，报警地点：%s，设备名称：%s ，为了您的用气安全，请立即开门开窗通风，关闭气源。如有需要帮助，请尽快联系燃气公司。"),
    //TYPE_2(2,"Bj2","报警器故障","尊敬的用户，您的设备故障，请及时维修！本地燃气热线电话：%s。"),
    TYPE_2(2,"Bj2","燃气报警器发生故障","您的设备发生故障了，报警地点：%s，设备名称：%s ，为了您的用气安全，请尽快检查。"),
    //TYPE_3(3,"Bj3","报警器寿命到期","尊敬的用户，报警器已累计使用5 年，使用寿命已到，请及时更换！本地燃气热线电话：%s。"),
    TYPE_3(3,"Bj3","燃气报警器寿命到期","您的燃气报警器已累计使用 5 年，使用寿命已到，地点：%s，设备名称：%s ，请及时更换！"),
    TYPE_4(4,"Bj6","接收器电池欠压（低于2.7V）","尊敬的用户，您的无线接收器电池电压低，请联系当地燃气公司及时更换电池！本地燃气热线电话：%s。"),
    TYPE_5(5,"Bj7","接收器电池欠压（低于2.4V）","尊敬的用户，您的无线接收器电池电量耗尽，发生燃气泄漏时已无法有效切断燃气，为防止意外发生请及时联系当地燃气公司更换电池！本地燃气热线电话：%s。"),
    TYPE_6(6,"Bj4","报警器离线","尊敬的用户，您的报警器已离线，请联系当地燃气公司处理！本地燃气热线电话：%s。"),
    TYPE_7(7,"Bj5","接收器离线","尊敬的用户，您的报警器接收器已离线，请联系当地燃气公司处理！本地燃气热线电话：%s。"),
    TYPE_8(8,"DCFGB","电磁阀关闭","尊敬的用户，您的报警器电磁阀已关闭，请联系当地燃气公司处理！本地燃气热线电话：%s。"),
    TYPE_9(9,"zjbjq10","接收器电磁阀故障","尊敬的用户，您的报警器无线接收器出现故障，请联系当地燃气公司处理！本地燃气热线电话：%s。"),
    TYPE_10(10,"zjbjq11","接收器电磁阀断开","尊敬的用户，您的报警器电磁阀未连接，请联系当地燃气公司！处理本地燃气热线电话：%s。"),
    TYPE_11(11,"bjq11","燃气报警器寿命到期","您的燃气报警器已累计使用 3 年，使用寿命已到，地点：%s，设备名称：%s ，请及时更换！"),
    TYPE_12(12,"bjq12","燃气报警器寿命到期","您的燃气报警器已累计使用 %d 年，使用寿命已到，地点：%s，设备名称：%s ，请及时更换！");

    /**
     * 消息类型
     */
    private final Integer type;
    /**
     * 短信模板code
     */
    private final String code;
    /**
     * 消息标题
     */
    private final String title;
    /**
     * 消息内容
     */
    private final String text;

    public static String getText(Integer type) {
        if (type == null) {
            return "";
        }
        for (PushMsgEnum pushMsgEnum : PushMsgEnum.values()) {
            if (pushMsgEnum.type.equals(type)) {
                return pushMsgEnum.text;
            }
        }
        return "";
    }

    public static String getCode(Integer type) {
        if (type == null) {
            return "";
        }
        for (PushMsgEnum pushMsgEnum : PushMsgEnum.values()) {
            if (pushMsgEnum.type.equals(type)) {
                return pushMsgEnum.code;
            }
        }
        return "";
    }

    public static String getTitle(Integer type) {
        if (type == null) {
            return "";
        }
        for (PushMsgEnum pushMsgEnum : PushMsgEnum.values()) {
            if (pushMsgEnum.type.equals(type)) {
                return pushMsgEnum.title;
            }
        }
        return "";
    }
}